﻿CREATE PROCEDURE [dbo].[yaf_topic_info](
                @TopicID     INT  = NULL,
                @ShowDeleted BIT  = 0)
AS
    BEGIN
        IF @TopicID = 0
        SET @TopicID = NULL
        IF @TopicID IS NULL
        BEGIN
            IF @ShowDeleted = 1
            SELECT *
            FROM   yaf_Topic
            ELSE
            SELECT *
            FROM   yaf_Topic
            WHERE  (Flags & 8) = 0
        END
        ELSE
        BEGIN
            IF @ShowDeleted = 1
            SELECT *
            FROM   yaf_Topic
            WHERE  TopicID = @TopicID
            ELSE
            SELECT *
            FROM   yaf_Topic
            WHERE  TopicID = @TopicID
            AND (Flags & 8) = 0
        END
    END


